#pragma once
#include "IPrimitive.h"
#include "Point.h"
#include "../Math/Matrix.h"
#include "../Texture/Texture.h"
class Traingle:public IPrimitive
{
public:
	Traingle(Point& p1 = PointZero,Point& p2 = PointZero,Point& p3 = PointZero);
	~Traingle(void);
	virtual void draw(IPixelDrawer* dr);
	void mulMat(Mat4& mat);
	Point p[3];
	Vec3 uv[3];
	void setTexture(Texture* texture,Vec3& uv0,Vec3& uv1,Vec3& uv2);
	void calcNormal();
	Texture* texture;
	bool isBackFace(IPixelDrawer* dr);
private:
	void horizonMapping(Point& pt,float k1,float k2,int endY,IPixelDrawer* dr,Vec3& uv,Vec3& uv1,Vec3& uv2,Point& pt1,Point& pt2);
	Vec3 _normal;	
};

